local table_name = "login_log"
local insert_sql = "INSERT INTO `%s` (`update_time`, `account`, `channel`, `userid`, `stage`, `type`, `action`, `para1`, `para2`, `para3`, `memo`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s');"

local M = {}

function M.write(conn, msg)
    local type, action, userid, account, channel, stage, para1, para2, para3, memo = table.unpack(msg.data)

    local update_time = os.date("%Y-%m-%d %H:%M:%S")
    local account = account or ""
    local channel = channel or ""
    local userid = userid or ""
    local stage = stage or ""
    local type = type or ""
    local action = action or ""
    local para1 = para1 or ""
    local para2 = para2 or ""
    local para3 = para3 or ""
    local memo = memo or ""
    local cmd = string.format(insert_sql, table_name, update_time, account, channel, userid, stage, type, action, para1, para2, para3, memo)
    -- print(cmd)
    conn:execute(cmd)
end

return M
